package com.itheima.exer.homework.hw1009;

import java.io.*;
import java.util.ArrayList;
import java.util.List;

public class StudentSerialThree {
    public static void main(String[] args) throws IOException, ClassNotFoundException {
        ObjectInputStream ois = new ObjectInputStream(new FileInputStream(new File("exercises\\c.txt")));
        Outmethod();
        ArrayList<Student> o =(ArrayList<Student>) ois.readObject();
        Object o1 = ois.readObject();
        System.out.println(o1);
        System.out.println(o);
    }

    private static void Outmethod() throws IOException {
        Student stu1 = new Student("张三",23);
        Student stu2 = new Student("李四",24);
        Student stu3 = new Student("王五",25);
        List<Student> list = new ArrayList<>(List.of(stu1,stu2,stu3));
        ObjectOutputStream oos = new ObjectOutputStream(new FileOutputStream(new File("exercises\\c.txt")));
        oos.writeObject(list);
        oos.close();
    }
}
